package com.baidu.shop.service;

import com.alibaba.fastjson.JSONObject;
import com.baidu.shop.base.Result;
import com.baidu.shop.dto.UserDTO;
import com.baidu.shop.entity.UserEntity;
import com.baidu.shop.validate.group.MingruiOperation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @ClassName: UserService
 * @Author: User
 * @date: 2020.10.13 14:19
 * @version: 1.0
 */
@Api(tags = "用户接口")
public interface UserService {
    @ApiOperation(value = "用户注册")
    @PostMapping(value = "user/register")
    Result<JSONObject> register(@Validated({MingruiOperation.Add.class}) @RequestBody UserDTO userDTO);

    @ApiOperation(value = "校验用户名和手机号唯一")
    @GetMapping(value = "user/check/{value}/{type}")
    Result<List<UserEntity>> checkUserNameOrPhone(
            @PathVariable("value") String value,
            @PathVariable("type") Integer type);

    @ApiOperation(value = "给手机发短信")
    @PostMapping(value = "user/sendValidCode")
    Result<JSONObject> sendValidCode(@RequestBody UserDTO userDTO);

    @ApiOperation(value = "Check短信验证码")
    @GetMapping(value = "user/checkValidCode/{phone}/{validCode}")
    Result<JSONObject> checkValidCode(
            @PathVariable(value ="phone") String phone,
            @PathVariable(value = "validCode") String validCode);
}
